package com.etc;

import java.awt.image.BufferedImage;

/**
 * 飞行物
 */
public abstract class FlyingObject {

    //图片
    protected BufferedImage image;
    //x 坐标
    protected int x;
    //y 坐标
    protected int y;
    //宽
    protected int width;
    //高
    protected int height;


    public BufferedImage getImage() {
        return image;
    }

    public void setImage(BufferedImage image) {
        this.image = image;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }


    public abstract void step();


    // 敌人被子弹是否打中
    public boolean shootBy(Bullet bullet){
        int x1 = this.x;
        int x2 = this.x + this.width;
        int y1 = this.y;
        int y2 = this.y + height;
        int x = bullet.x;
        int y = bullet.y;
        if ( (x > x1 && x < x2) && ( y>y1 && y<y2)){
            return true;
        }

        return false;
    }

    /**
     * 判断飞行物是否出界
     * @return
     */
    public abstract boolean outBounds();


}
